# 1、导包
import pymysql
# 2、创建连接，连接数据库
conn = pymysql.connect(user="root",  # The first four arguments is based on DB-API 2.0 recommendation.
        password="123456",
        host="121.40.136.164",
        database="litemall",
        port = 3306)
# 3、获取游标
cursor = conn.cursor()

user_sql = "INSERT INTO `litemall`.`litemall_user`" \
           "(`username`, `password`, `gender`, `birthday`, `last_login_time`, `last_login_ip`, `user_level`, `nickname`, `mobile`, `avatar`, `weixin_openid`, `session_key`, `status`, `add_time`, `update_time`, `deleted`) " \
           "VALUES ('user{}', '$2a$10$lTu9qi0hr19OC800Db.eludFr0AXuJUSrMHi/iPYhKRlPFeqJxlye', 1, NULL, '2021-11-14 17:09:37', '61.242.134.225', 0, 'user123', '{}', '', '', '', 0, '2019-04-20 22:17:43', '2021-11-14 17:09:37', 0);"
# 4、循环执行sql
user_start_sql = 1000
for i in range(100):

        user_name = user_start_sql + i
        user_mobile = "132588" + str(user_name)

        # good_id = good_id_start_sql+1

        sql = user_sql.format(user_name,user_mobile )
        print(sql)
        cursor.execute(sql)
        conn.commit()


# # 获取游标第一行数据
# print("获取查询一行数据前游标的位置：",cursor.rownumber)
# result1 = cursor.fetchone()
# print(result1)
#
#
# # 5、获取全部查询数据
# print("获取查询所有数据前游标的位置：",cursor.rownumber)
# # 重置游标位置
# cursor.rownumber = 0
# result = cursor.fetchall()
# print(result)
#
# print("获取所有数据前游标的位置：",cursor.rowcount)
# 6、关闭游标
cursor.close()
# 7、关闭连接
conn.close()
